package nancal.mp


import nbcp.base.extend.*
import nbcp.base.json.*
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.extension.ExtendWith
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.context.annotation.ComponentScan
import org.springframework.test.context.junit.jupiter.SpringExtension
import java.time.Duration

/**
 * Created by udi on 17-3-27.
 */


@ExtendWith(SpringExtension::class)
@AutoConfigureMockMvc
@SpringBootTest()
@ComponentScan(basePackages = arrayOf("com.nbcp", "nancal.mp"))
class TestBase {
    init {
//        GenericXmlApplicationContext().environment.setActiveProfiles("test")

//        println(SpringUtil.context.environment.activeProfiles)
        //ParserConfig.getGlobalInstance().putDeserializer(ObjectId::class.java, ObjectIdDeserializer())
    }


    fun execTimes(name: String, times: Int, func: (Int) -> String) {
        println("${name} 执行1000次:")
        var startAt = System.currentTimeMillis()
        for (i in 1..times) {
            var ret = func(i)
            if (ret.isEmpty()) continue

            println(ret)
        }
        var endAt = System.currentTimeMillis()

        println(Duration.ofMillis(endAt - startAt).toSummary())
    }

    @Test
    fun abc(){
        println("OK")
    }
}